const router = require('koa-router')()
const HomeController = require('./controller/home')

module.exports = (app) => {
  // router.get('/shop/v1/activities/:id', HomeController.home(this.params.id))
  router.get('/', async function (ctx, next) {
    ctx.response.type = 'text/html'
    ctx.response.body = '<h1>index</h1>'
  })

  router.get('/home', async function (ctx, next) {
    ctx.response.type = 'text/html'
    ctx.response.body = '<h1>home</h1>'
  })
  router.get('/shop/v1/activities/:id', async function (ctx, next) {
    const id = ctx.params.id
    await HomeController.home(ctx, next, id)
  })

  router.all('/*', async (ctx, next) => {
    await next()
    ctx.response.body = '<h1>404 Not Found</h1>'
  })

  app.use(router.routes())
    .use(router.allowedMethods())
}